﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>课程管理</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
    <link rel="stylesheet" href="http://g.alicdn.com/msui/sm/0.6.2/css/sm-extend.min.css">
    <link rel="stylesheet" type="text/css" href="/View_Mobile/UI/KSGL/css/style.css">
    
</head>
<body ms-controller="UI_KCGLLIST"> 
    <div class="page-group">
        <!-- 单个page ,第一个.page默认被展示-->
        <div class="page">
            <!-- 标题栏 -->
            <header class="bar bar-nav" id="bar">
                <a class="icon icon-left pull-left"></a>
                <h1 class="title">课程列表</h1>
            </header>
            <!-- 这里是页面内容区 -->
            <div class="content infinite-scroll infinite-scroll-bottom">
                <div class="buttons-tab fixed-tab" data-offset="44">
                    <a href="" class="tab-link button">
                        <span id="btnSelect">{{TypeName}}</span>
                        <span class="iconfont icon-xiala"></span>
                    </a>
                    <div id="answer-sheet" class="answer-sheet">
                        <div class="answer-panel ulDiv">
                            <ul>
                                <li ms-click="SelectType('')">全部课程</li>
                                <li ms-repeat-item="kcflData" ms-click="SelectType(item)"> {{item.TypeName}}</li>
                            </ul>
                        </div>
                    </div>
                </div>

                <!-- 课程列表 -->
                <div class="list-block media-list nomargin ">
                    <ul>
                        <li ms-repeat-item="KCData">
                            <a ms-attr-href="/View_Mobile/UI/KSGL/UI_KCGL.html?id={{item.ID}}" class="item-link item-content" external>
                                <div class="item-media">
                                    <img onerror="this.src = 'http://img.mukewang.com/5704aa2f0001248206000338-228-128.jpg'" ms-attr-src="/View/Common/DownLoadFile.aspx?fileId={{item.KCFM.split(',')[0]}}" style="width:90px;height:50px;">

                                </div>
                                <div class="item-inner">

                                    <div class="item-title-row">
                                        <div class="item-title">{{item.KCName}}</div>

                                    </div>
                                    <div class="item-subtitle c999 ft7">
                                        <span class="mr5"><i class="iconfont icon-ren"></i>讲师:{{item.KCZJR}}</span>
                                        <span><i class="iconfont icon-shijian"></i>时长:{{item.KSS}}</span>
                                    </div>
                                </div>
                            </a>
                        </li>
                    </ul>
                </div>
                <p class="no-content" ms-if="loadtip"> {{loadtip}}</p>
                <div class="infinite-scroll-preloader">
                    <div class="preloader"></div>
                </div>
            </div>
        </div>
    </div>

    <script src="/View_Mobile/JS/layer/layer.m.js"></script>
    <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.5.8/js/sm.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.5.8/js/sm-extend.min.js' charset='utf-8'></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
    <script src="/View_Mobile/JS/touch/toucher.js"></script>
    <script src="/View_Mobile/JS/avalon.mobile.min.js"></script>
    <script src="/View_Mobile/JS/raty/jquery.raty.js?v=1.3"></script>
    <script src="/View_Mobile/JS/ComFunJS.js?jsver=20160425"></script>
    <script type="text/javascript">
        $(function () {
            
            var h1 = document.getElementById("bar").offsetHeight;
            var h2 = window.innerHeight - h1 * 2;
            document.getElementById("answer-sheet").style.height = h2 + "px";
            document.getElementById("answer-sheet").style.top = h1 * 2 + "px";
            // 课程筛选
            $("#btnSelect").click(function () {
                $("#answer-sheet").toggle();
            });
            $('.ulDiv ul li').on('click', function () {
                var selTxt = $(this).text();
                $('#btnSelect').text(selTxt);
                $(this).addClass("cor").siblings().removeClass("cor");
                $('.answer-sheet').hide();
            });
        });

    </script>
    <script>
        var model = avalon.define({
            $id: "UI_KCGLLIST",
            KCData: [],
            kcflData:[],
            kcflType:"",   
            page: 1,
            loadtip: "",
            loading:false, 
            pagecount: 8,
            TypeName:"全部课程",
            SelectType: function (type) {
                model.kcflType = type.ID;
                model.TypeName = type.TypeName;
                model.getData();
                $('.answer-sheet').hide();
            },
            GetList: function () {
                if (model.loading) return;
                model.loading = true;
                $.getJSON('/API/VIEWAPI.ashx?Action=KCGL_GETKCGLLIST', { p: model.page, P1: model.kcflType, pagecount: model.pagecount }, function (resultData) {
                    model.loading = false;
                    if (resultData.ErrorMsg == "") {
                        if (model.page == 1 && resultData.Result.length == 0) {
                            model.loadtip = '没有找到数据哦'
                        } 
                        model.KCData.pushArray(resultData.Result);
                        //判断是否加载完毕
                        if (resultData.Result.length < model.pagecount) {
                            // 加载完毕，则注销无限加载事件，以防不必要的加载
                            $.detachInfiniteScroll($('.infinite-scroll'));
                            // 删除加载提示符
                            $('.infinite-scroll-preloader').hide();
                            return;
                        }
                        $.refreshScroller();
                        model.page += 1;

                    }
                }) 
            }, getData: function () {
                $.attachInfiniteScroll($('.infinite-scroll'))
                model.loadtip = "";
                $('.infinite-scroll-preloader').show();
                model.KCData.clear();
                model.page = 1; 
                model.GetList();
            },

        })
        avalon.ready(function () {
            // 注册'infinite'事件处理函数
            $(document).on('infinite', '.infinite-scroll-bottom', function () {
                model.GetList();
            });
            $.init();
            model.getData();
            $.getJSON('/API/VIEWAPI.ashx?Action=XTGL_GETZIDIANLIST', { P1: 24 }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    model.kcflData = resultData.Result;

                }
            })
        }) //# sourceURL=RESULT.js;
    </script>
</body>

</html>
